<template>
  <div class="fillcontain">
    <div class="box">
      <h3>用户搜索</h3>
      <el-form :inline="true" :model="search" class="demo-form-inline">
        <el-form-item label="手机号：">
          <el-input v-model="search.phone" placeholder="请输入手机号"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button size="small">重置</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="small">查询搜索</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="box flex-between">
      <h3>用户列表</h3>
      <el-button size="small">添加</el-button>
    </div>
    <div class="table_container box">
      <el-table :data="tableData" highlight-current-row style="width: 100%">
        <el-table-column type="index" width="100"></el-table-column>
        <el-table-column property="name" label="姓名" width="180"></el-table-column>
        <el-table-column property="phone" label="手机号" width="180"></el-table-column>
        <el-table-column property="building" label="楼栋" width="180"></el-table-column>
        <el-table-column property="car" label="车辆" width="180"></el-table-column>
        <el-table-column property="registeTime" label="注册时间" width="180"></el-table-column>
        <el-table-column fixed="right" label="操作" width="100">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small">详情</el-button>
            <el-button type="text" size="small">车辆</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="Pagination" style="text-align: left;margin-top: 10px;">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-size="10"
          layout="total, prev, pager, next"
          :total="count"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      search: {
        phone: ""
      },
      tableData: [
        {
          name: "王小虎",
          phone: "12011143811",
          building: "1-1-502",
          car: 1,
          registeTime: "2016-05-02 18:00:30"
        },
        {
          name: "王小虎",
          phone: "15211111111",
          building: "1-1-503",
          car: 2,
          registeTime: "2017-07-07 17:17:17"
        },
        {
          name: "王小虎",
          phone: "12011143811",
          building: "1-1-502",
          car: 1,
          registeTime: "2016-05-02 18:00:30"
        },
        {
          name: "王小虎",
          phone: "12011143811",
          building: "1-1-502",
          car: 1,
          registeTime: "2016-05-02 18:00:30"
        },
        {
          name: "王小虎",
          phone: "12011143811",
          building: "1-1-502",
          car: 1,
          registeTime: "2016-05-02 18:00:30"
        },
        {
          name: "王小虎",
          phone: "12011143811",
          building: "1-1-502",
          car: 1,
          registeTime: "2016-05-02 18:00:30"
        },
        {
          name: "王小虎",
          phone: "12011143811",
          building: "1-1-502",
          car: 1,
          registeTime: "2016-05-02 18:00:30"
        },
        {
          name: "王小虎",
          phone: "12011143811",
          building: "1-1-502",
          car: 1,
          registeTime: "2016-05-02 18:00:30"
        },
        {
          name: "王小虎",
          phone: "12011143811",
          building: "1-1-502",
          car: 1,
          registeTime: "2016-05-02 18:00:30"
        },
        {
          name: "王小虎",
          phone: "12011143811",
          building: "1-1-502",
          car: 1,
          registeTime: "2016-05-02 18:00:30"
        }
      ],
      currentRow: 10,
      offset: 0,
      limit: 10,
      count: 0,
      currentPage: 1
    };
  },
  components: {},
  created() {
    // this.initData();
  },
  methods: {
    // async initData(){
    //     try{
    //         const countData = await getUserCount();
    //         if (countData.status == 1) {
    //             this.count = countData.count;
    //         }else{
    //             throw new Error('获取数据失败');
    //         }
    //         this.getUsers();
    //     }catch(err){
    //         console.log('获取数据失败', err);
    //     }
    // },
    handleClick(row) {
      console.log(row);
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.offset = (val - 1) * this.limit;
      // this.getUsers()
    }
    // async getUsers(){
    //     const Users = await getUserList({offset: this.offset, limit: this.limit});
    //     this.tableData = [];
    //     Users.forEach(item => {
    //         const tableData = {};
    //         tableData.username = item.username;
    //         tableData.registe_time = item.registe_time;
    //         tableData.city = item.city;
    //         this.tableData.push(tableData);
    //     })
    // }
  }
};
</script>

<style lang="less">
// @import url("../style/mixin.less");
@import url("../style/main.less");
.table_container {
  padding: 20px;
}
.box {
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid #eee;
  border-radius: 4px;
  .el-form-item {
    margin: 20px 20px 0 0;
  }
}
</style>
